<?php
header('Content-Type: text/html; charset=UTF-8'); 
	define('INCLUDE_CHECK',true);
	include 'config/connect.php';
	include 'config/get_application_settings.php';
	
	
	session_name('PHPVolunteerManagent');
	session_start();


	//Check to see if the users needs to reset thier password before doing anything else...
	if(isset($_SESSION['volunteer_id'])) {
		$sql = "SELECT * FROM volunteers WHERE volunteer_id = '$_SESSION[volunteer_id]'";
		$result = mysql_fetch_assoc(mysql_query($sql));
		echo mysql_error();
		$force_password_change = $result['volunteer_force_password_change'];
		if($force_password_change == '1') {
			if($_GET['p'] != 'change_password') {
				header('Location: ?p=change_password');
			}
		}
	}

	if(!isset($_SESSION['volunteer_id'])) {
		if($_GET['p'] !='login') {
			header('Location: ?p=login');
		}
	}
	
	if(isset($_SESSION['volunteer_id'])) {
		if(!isset($_GET['p'])) {
			header('Location: ?p=dashboard');
		}
	}
	
	if($_GET['p'] == 'logoff') {
		session_start();
		session_destroy();
		header('Location: ?p=login');
	}
	
	include 'mods/login/process_login.php';

?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//ES"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<link rel="icon" 
      type="image/png" 
      href="img/icons/VMS.png">
	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
		<title><?php echo $title; ?> | <?php echo $organization_name; ?></title>
		<link href="css/styles.css" rel="stylesheet"/>
		<link href="css/messages.css" rel="stylesheet"/>
        <link href="css/kendo/kendo.common.min.css" rel="stylesheet"/>
        <link href="css/kendo/kendo.silver.min.css" rel="stylesheet"/>
        <script src="js/kendo/jquery.min.js"></script>
        <script src="js/jquery.form.js"></script>
        <script src="js/kendo/kendo.all.min.js"></script>
<script type="text/javascript">

function crear_skill(obj) {
 

  var combo=document.getElementById('skill_combo');
  var out=document.getElementById('out_span');
  var elmTBODY = document.getElementById('skill_table'); 
  var elmTR;
  var elmTD;
  var combo_val=combo.value;
  var skill_id= combo_val.replace("skill_id_","");
  elmTR = elmTBODY.insertRow(1);

//Titulo
  elmTD = elmTR.insertCell(0);
  elmText=document.createElement('label');
  elmText.innerHTML=combo.options[combo.selectedIndex].text;
  //elmText = document.createTextNode(combo.options[combo.selectedIndex].text);
  elmTD.appendChild(elmText);

//aprobado
elmTD = elmTR.insertCell(1);
  ele1 = document.createElement('input'); 
  ele1.type = 'radio';
  ele1.value = '1'; 
  ele1.name = 'skill['+skill_id+']';
 // ele.id= 'skill'; 
  out.innerHTML='pruba'+skill_id;
  elmTD.appendChild(ele1); // 7

//cursado

elmTD = elmTR.insertCell(2);
  ele = document.createElement('input'); 
  ele.type = 'radio';
  ele.value = '2'; 
  ele.name = ele1.name;//+skill_id;
  //ele.id= 'skill'; 
  //out.innerHTML='pruba'+skill_id;
  elmTD.appendChild(ele); // 7


//borrar
  elmTD = elmTR.insertCell(3);
  ele = document.createElement('input'); 
  ele.type = 'button'; 
  ele.value = 'Borrar'; 
  ele.name = 'tr'; 
  ele.onclick = function () {appendOptionLast(skill_id);
			    elmTBODY.deleteRow(elmTR.rowIndex);} 
//  out.innerHTML='pruba'+elmTR.rowIndex;
  elmTD.appendChild(ele); 
//hidden con el nombre
	elmTD=elmTR.insertCell(4);
	ele = document.createElement('input');
	ele.type ='hidden';
	ele.value =combo.options[combo.selectedIndex].text;
	ele.id ='hidden_skill_'+skill_id;
	elmTD.appendChild(ele);

//borro el curso seleccionado
combo.remove(combo.selectedIndex);
}

function appendOptionLast(num)
{
  var elOptNew = document.createElement('option');
  var out=document.getElementById('out_span');
  out.innerHTML='borrado='+num;
  elOptNew.text = document.getElementById('hidden_skill_'+num).value;
  elOptNew.value = 'skill_id_'+num ;
  var elSel = document.getElementById('skill_combo');

  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
}
</script>
	</head>

	<body>


